var mongoose = require('mongoose');
var Schema = mongoose.Schema;

/**
 * comments: [{
     *  如果已登录
     *  uid: ObjectId,
     *  username: String,
     *  usericon: String,
     *  userdep: String,
     *  date: Date,
     *  content: String
     * },
 * {
     *  如果未登录
     *  name: String,
     *  email: String,
     *  ip: String,
     *  content: String
     * }
 * ...
 * ]
 */

//单独抽出来的原因是还有一个replyList
var CommentSchema = new Schema({
    
    uid: Schema.Types.ObjectId,
    username: String,
    usericon: String,
    userdep: String,
    userip: String,

    date: {
        type: Date,
        default: Date.now
    },
    content: {
        type: String,
        required: '评论不能为空'
    },
    replyList: [Schema.Types.Mixed]
});

mongoose.model('Comment', CommentSchema);

console.log('Comment模型已经建立...');
